#!/bin/bash
if [ -d .modules ];then 
  echo "Clear old .modules directory"
  rm -rf .modules
fi
echo "[checking remote server all tags]"
git ls-remote --tags

read -p "Input new tags, e.g: (v1.0.x) Enter: " TAG
# TAG=$1

if [ -z $TAG ];then
  echo "missing TAG"
  exit 1
fi

if [ ! -d .modules ];then 
  cp -r modules .modules
fi
cd .modules
git init
git remote add origin git@code.deeproute.ai:deeproute-org/cloud/cloud/k8s-deployment/ops-terraform.git
git add .
git commit -am "add tag $TAG"
git tag module.$TAG
git push origin module.$TAG